{	Problem: http://codeforces.ru/problemset/problem/23/A
	Verdict: Accepted
}
var s,s1,t:string; i,j,r:longint;
begin
readln(s);
r:=0;
i:=length(s)-1;
while (i>0) and (r=0) do begin
    for j:=1 to length(S)-i+1 do begin
        t:=copy(s,j,i);
        if pos(t,s)<>0 then begin
            s1:=copy(s,pos(t,s)+1,length(s)-pos(t,s));
            if pos(t,s1)<>0 then r:=i;
        end;
    end;
    dec(i);
end;
write(r);
end.